import http from './axios'

/* 博客相关 */

// 添加博客
export const AddBlog = blog => http('POST', '/blog/add', blog)
// 修改博客
export const UpdateBlog = blog => http('PUT', '/blog/update', blog)
// 增加博客阅读量
export const ViewBlog = id => http('PUT', `/blog/view/${id}`)
// 用户删除博客
export const DeleteBlogForUser = id => http('DELETE', '/blog/delete', { id })
// 管理端删除博客
export const DeleteBlogForManage = id => http('DELETE', '/blog/manageDelete', { id })
// 查询博客列表
export const GetBlogPage = (authorDomain, classificationId, search, page) => http('GET', '/blog/page', {
  authorDomain,
  classificationId,
  search,
  page
})
// 查询博客详情
export const GetBlogDetail = id => http('GET', '/blog/detail', { id })
// 查询用于编辑的博客详情
export const GetBlogDetailForUpdate = id => http('GET', '/blog/updateDetail', { id })
// 查询推荐博客
export const GetRecommendBlog = time => http('GET', '/blog/recommend', { time })
// 搜索博客
export const GetSearchBlog = (str, time) => http('GET', '/blog/search', {
  str,
  time
})

/* 分类相关 */

// 添加分类
export const AddClassification = name => http('POST', '/classification/add', { name })
// 修改分类名称
export const UpdateClassification = classification => http('PUT', '/classification/update', classification)
// 用户删除分类
export const DeleteClassificationForUser = id => http('DELETE', '/classification/delete', { id })
// 管理端删除分类
export const DeleteClassificationForManage = id => http('DELETE', '/classification/manageDelete', { id })
// 查询分页的分类列表
export const GetClassificationPage = (name, userName, page, size) => http('GET', '/classification/page', {
  name,
  userName,
  page,
  size
})
// 查询分类列表
export const GetClassificationList = () => http('GET', '/classification/list')
// 通过域名查询分类列表
export const GetClassificationListByDomain = domain => http('GET', '/classification/list/' + domain)

/* 标签相关 */

// 添加标签
export const AddTag = name => http('POST', '/tag/add', { name })
// 修改标签名称
export const UpdateTag = tag => http('PUT', '/tag/update', tag)
// 删除标签
export const DeleteTag = id => http('DELETE', '/tag/delete', { id })
// 查询分页的标签列表
export const GetTagPage = (name, userName, page, size) => http('GET', '/tag/page', {
  name,
  userName,
  page,
  size
})
// 查询标签列表
export const GetTagList = () => http('GET', '/tag/list')

/* 评论相关 */

// 添加评论
export const AddComment = comment => http('POST', '/comment/add', comment)
// 用户删除评论
export const DeleteCommentForUser = id => http('DELETE', '/comment/delete', { id })
// 管理端删除评论
export const DeleteCommentForManage = id => http('DELETE', '/comment/manageDelete', { id })
// 查询分页的评论列表
export const GetCommentPage = (blogName, userName, content, page, size) => http('GET', '/comment/page', {
  blogName,
  userName,
  content,
  page,
  size
})
// 查询评论列表
export const GetCommentList = (blogId, time) => http('GET', '/comment/list', {
  blogId,
  time
})
